//
//  SQRZViewController.m
//  YaDiuDiu
//
//  Created by 欧洪飞 on 2017/8/25.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "SQRZViewController.h"

#import "SJRZView.h"
#import "SQStateViewController.h"
#import "MapSelPlaceViewController.h"

#import "SGQRCodeScanningVC.h"
#import <AVFoundation/AVFoundation.h>
@interface SQRZViewController ()<UIPickerViewDelegate,UIPickerViewDataSource,UIImagePickerControllerDelegate,UINavigationControllerDelegate,MapSelPlaceViewControllerDelegate,SGQRCodeScanningVCDelegate>{
    SJRZView *view;
    UIView *bottomView;
    NSArray *arr;//数据源
    NSArray *arrType;
    UIImagePickerController *imagepc;
    NSMutableDictionary *dic;//入驻资料详情
}

@property (nonatomic,copy)NSString *titles;//商户类型
@property (nonatomic,copy)NSString *merchanttype;//
@property (nonatomic,assign)NSInteger MyTags;//图片标示
@property (nonatomic,copy)NSString *imgUrl1;
@property (nonatomic,copy)NSString *imgUrl2;
@property (nonatomic,copy)NSString *imgUrl3;

@end

@implementation SQRZViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setBGColor];
    [self showNav:@"申请入驻"];
    dic = [NSMutableDictionary dictionary];
    arrType = @[@"",@"房产商家",@"购车商家",@"干洗商家",@"开锁商家",@"果蔬商家",@"苦力商家",@"快递商家",@"家政商家",@"洗车商家",@"上户商家"];
    [self loadData];
    if (_merid.length > 0) {
        [self loadData2];
    }else{
        [self loadUI];
        
    }
    
}

- (void)loadUI{
    UIScrollView *sclView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight-64)];
    sclView.contentSize = CGSizeMake(ScreenWidth, 750);
    [self.view addSubview:sclView];
    
    view = [[[NSBundle mainBundle] loadNibNamed:@"SJRZView" owner:nil options:nil] lastObject];
    view.frame = CGRectMake(0, 0, ScreenWidth, 750);
    [sclView addSubview:view];
    
    [view.btnSQ addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click1)];
    view.labSelType.userInteractionEnabled = YES;
    [view.labSelType addGestureRecognizer:tap1];
    
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click2:)];
    view.image1.userInteractionEnabled = YES;
    [view.image1 addGestureRecognizer:tap2];
    UIView *singleView2 = [tap2 view];
    singleView2.tag = 1;
    
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click2:)];
    view.image2.userInteractionEnabled = YES;
    [view.image2 addGestureRecognizer:tap3];
    UIView *singleView3 = [tap3 view];
    singleView3.tag = 2;
    
    UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click2:)];
    view.image3.userInteractionEnabled = YES;
    [view.image3 addGestureRecognizer:tap4];
    UIView *singleView4 = [tap4 view];
    singleView4.tag = 3;
    
    UITapGestureRecognizer *tap5 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click5)];
    [view.labSelMap addGestureRecognizer:tap5];
    view.labSelMap.userInteractionEnabled = YES;
    
    UITapGestureRecognizer *tap6 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click6)];
    view.labYQM.userInteractionEnabled = YES;
    [view.labYQM addGestureRecognizer:tap6];
    
}
//修改资料
- (void)loadUI2{
    UIScrollView *sclView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight-64)];
    sclView.contentSize = CGSizeMake(ScreenWidth, 750);
    [self.view addSubview:sclView];
    
    view = [[[NSBundle mainBundle] loadNibNamed:@"SJRZView" owner:nil options:nil] lastObject];
    view.frame = CGRectMake(0, 0, ScreenWidth, 750);
    [sclView addSubview:view];
    
    [view.btnSQ addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click1)];
    view.labSelType.userInteractionEnabled = YES;
    [view.labSelType addGestureRecognizer:tap1];
    
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click2:)];
    view.image1.userInteractionEnabled = YES;
    [view.image1 addGestureRecognizer:tap2];
    UIView *singleView2 = [tap2 view];
    singleView2.tag = 1;
    
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click2:)];
    view.image2.userInteractionEnabled = YES;
    [view.image2 addGestureRecognizer:tap3];
    UIView *singleView3 = [tap3 view];
    singleView3.tag = 2;
    
    UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click2:)];
    view.image3.userInteractionEnabled = YES;
    [view.image3 addGestureRecognizer:tap4];
    UIView *singleView4 = [tap4 view];
    singleView4.tag = 3;
    
    UITapGestureRecognizer *tap5 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click5)];
    [view.labSelMap addGestureRecognizer:tap5];
    view.labSelMap.userInteractionEnabled = YES;
    //邀请码
    UITapGestureRecognizer *tap6 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click6)];
    view.labYQM.userInteractionEnabled = YES;
    [view.labYQM addGestureRecognizer:tap6];
    
    //赋值
    NSString *merchanttype = [NSString stringWithFormat:@"%li",[[dic objectForKey:@"merchanttype"] integerValue]];
    NSInteger tag = [merchanttype integerValue];
    view.labSelType.text = arrType[tag];
    //
    view.text1.text = [dic objectForKey:@"name"];
    view.text2.text = [dic objectForKey:@"legalname"];
    view.text3.text = [dic objectForKey:@"idcardno"];
    view.text4.text = [dic objectForKey:@"phone"];
    NSString *beinvitedcode = [dic objectForKey:@"beinvitedcode"];
    if (beinvitedcode.length <=0) {
        view.labYQM.text = @"请扫描邀请码（选填）";
    }else{
        view.labYQM.text = [dic objectForKey:@"beinvitedcode"];
    }
    
    view.text6.text = [dic objectForKey:@"email"];
    
    NSString *imgUrl1 = [NSString stringWithFormat:@"%@%@",[user objectForKey:@"ImageUrl"],[dic objectForKey:@"idcardfront"]];
    NSString *imgUrl2 = [NSString stringWithFormat:@"%@%@",[user objectForKey:@"ImageUrl"],[dic objectForKey:@"idcardreverse"]];
    NSString *imgUrl3 = [NSString stringWithFormat:@"%@%@",[user objectForKey:@"ImageUrl"],[dic objectForKey:@"license"]];
    [view.image1 sd_setImageWithURL:[NSURL URLWithString:imgUrl1] placeholderImage:[UIImage imageNamed:@""]];
    [view.image2 sd_setImageWithURL:[NSURL URLWithString:imgUrl2] placeholderImage:[UIImage imageNamed:@""]];
    [view.image3 sd_setImageWithURL:[NSURL URLWithString:imgUrl3] placeholderImage:[UIImage imageNamed:@""]];
    
    view.labSelMap.text = [NSString stringWithFormat:@"%@%@%@",[dic objectForKey:@"province"],[dic objectForKey:@"city"],[dic objectForKey:@"dist"]];
    view.textDIZhi.text = [dic objectForKey:@"suite"];
    
}

//选择省市区
- (void)click5{
    MapSelPlaceViewController *place = [[MapSelPlaceViewController alloc] init];
    place.delegate = self;
    [self.navigationController pushViewController:place animated:YES];
    
}

- (void)click6{
    // 1、 获取摄像设备
    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
    if (device) {
        AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
        if (status == AVAuthorizationStatusNotDetermined) {
            [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
                if (granted) {
                    dispatch_sync(dispatch_get_main_queue(), ^{
                        SGQRCodeScanningVC *vc = [[SGQRCodeScanningVC alloc] init];
                        [self.navigationController pushViewController:vc animated:YES];
                    });
                    // 用户第一次同意了访问相机权限
                    NSLog(@"用户第一次同意了访问相机权限 - - %@", [NSThread currentThread]);
                    
                } else {
                    // 用户第一次拒绝了访问相机权限
                    NSLog(@"用户第一次拒绝了访问相机权限 - - %@", [NSThread currentThread]);
                }
            }];
        } else if (status == AVAuthorizationStatusAuthorized) { // 用户允许当前应用访问相机
            SGQRCodeScanningVC *vc = [[SGQRCodeScanningVC alloc] init];
            vc.delegate = self;
            [self.navigationController pushViewController:vc animated:YES];
        } else if (status == AVAuthorizationStatusDenied) { // 用户拒绝当前应用访问相机
            UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请去-> [设置 - 隐私 - 相机 - SGQRCodeExample] 打开访问开关" preferredStyle:(UIAlertControllerStyleAlert)];
            UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
                
            }];
            
            [alertC addAction:alertA];
            [self presentViewController:alertC animated:YES completion:nil];
            
        } else if (status == AVAuthorizationStatusRestricted) {
            NSLog(@"因为系统原因, 无法访问相册");
        }
    } else {
        UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"未检测到您的摄像头" preferredStyle:(UIAlertControllerStyleAlert)];
        UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        
        [alertC addAction:alertA];
        [self presentViewController:alertC animated:YES completion:nil];
    }
    
}

#pragma - mark SGQRCodeScanningVCDelegate
-(void)sendText:(NSString *)str{
    view.labYQM.text = str;
    view.labYQM.textColor = [UIColor blackColor];
}

#pragma -mark MapSelPlaceViewControllerDelegate
-(void)sendText:(NSString *)text Province:(NSString *)proce City:(NSString *)city Area:(NSString *)area{
    view.labSelMap.text = [NSString stringWithFormat:@"%@-%@-%@",proce,city,area];
    view.textDIZhi.text = text;
    
}

-(void)sendLat:(NSString *)lat sendLng:(NSString *)lng{
    
}

-(void)sendAddress:(NSString *)address Det:(NSString *)det{
    
}

//立即申请
- (void)click{
    if ([view.labSelType.text isEqualToString:@"请选择"]) {

        [LICGToast showWithText:@"请选择商户类型"];
        return;
    }else if (view.text1.text.length == 0){

        [LICGToast showWithText:@"请填写商户名称"];
        return;
    }else if (view.text2.text.length == 0){

        [LICGToast showWithText:@"请填写法人姓名"];
        return;
    }else if ([self checkIdentityCardNo:view.text3.text] == 0){

        [LICGToast showWithText:@"身份证号不正确"];
        return;
    }else if ([self validateMobile:view.text4.text] == 0){
        
        [LICGToast showWithText:@"手机号格式不正确"];
        return;
    }else if ([self validateEmail:view.text6.text] == 0){

        [LICGToast showWithText:@"请填写正确格式的邮箱"];
        return;
    }else if (_imgUrl1.length == 0){

        [LICGToast showWithText:@"请上传身份证正面照"];
        return;
    }else if (_imgUrl2.length == 0){
        
        [LICGToast showWithText:@"请上传身份证反面照"];
        return;
    }else if (_imgUrl3.length == 0){

        [LICGToast showWithText:@"请上传企业执照"];
        return;
    }else if ([view.labSelMap.text isEqualToString:@"请选择省市区"]){
        
        [LICGToast showWithText:@"请选择省市区"];
        return;
    }else if (view.textDIZhi.text.length == 0){
        [self showAlert:@"请填写具体地址"];
        return;
    }
    
    NSString *str = [NSString stringWithFormat:@"%@890d69e502d1d37a9e84335ccefece57",[user objectForKey:@"token2"]];
    NSString *token = [LCMD5Tool md5:str];
    NSMutableDictionary *parmas = [NSMutableDictionary dictionary];
    [parmas setObject:[user objectForKey:@"userid"] forKey:@"userid"];
    [parmas setObject:view.text1.text forKey:@"name"];
    [parmas setObject:_merchanttype forKey:@"merchanttype"];
    [parmas setObject:view.text2.text forKey:@"legalname"];
    [parmas setObject:view.text4.text forKey:@"phone"];
    [parmas setObject:@"重庆市" forKey:@"province"];
    [parmas setObject:@"重庆市" forKey:@"city"];
    [parmas setObject:@"九龙坡区" forKey:@"dist"];
    [parmas setObject:view.textDIZhi.text forKey:@"suite"];
    [parmas setObject:@"106.522532" forKey:@"longitude"];
    [parmas setObject:@"29.514729" forKey:@"latitude"];
    [parmas setObject:view.text6.text forKey:@"email"];
    [parmas setObject:_imgUrl3 forKey:@"license"];
    [parmas setObject:_imgUrl1 forKey:@"idcardfront"];
    [parmas setObject:_imgUrl2 forKey:@"idcardreverse"];
    [parmas setObject:token forKey:@"verifiToken"];
//    [parmas setObject:view.text5.text forKey:@"beinvitedcode"];//邀请码
    [parmas setObject:view.text3.text forKey:@"idcardno"];
    NSString *url;
    if (_merid.length > 0) {//修改申请资料
        [parmas setObject:_merid forKey:@"id"];//商家ID
        [parmas setObject:[dic objectForKey:@"profile"] forKey:@"profile"];
        [parmas setObject:@"2" forKey:@"status"];
        url = [NSString stringWithFormat:@"%@/App/Forbusiness/modifieddata",urlHead];
    }else{
        url = [NSString stringWithFormat:@"%@/App/Forbusiness/applybusiness",urlHead];
    }
    NSLog(@"parmas:%@",parmas);
    [[AFHTTPSessionManager manager] POST:url parameters:parmas success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"res:%@",responseObject);
        NSString *error = [NSString stringWithFormat:@"%li",[[responseObject objectForKey:@"error"] integerValue]];
        if ([error integerValue] == 200) {
            [self.navigationController popViewControllerAnimated:YES];
        }
        [LICGToast showWithText:[responseObject objectForKey:@"mssage"]];
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"error:%@",error);
    }];
}

- (void)click2:(id)sender{
    UITapGestureRecognizer *tap = (UITapGestureRecognizer *)sender;
    NSInteger tags = [tap view].tag;
    _MyTags = tags;
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self pickerPicture];
    }];
    
    UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"从相册中获取" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self pickerPictureFromAlbum];
    }];
    
    [alert addAction:action1];
    [alert addAction:action2];
    [alert addAction:action3];
    [self presentViewController:alert animated:YES completion:nil];
    
}
//拍照获取
- (void)pickerPicture{
    if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) {
        NSLog(@"用前置摄像头");
        imagepc = [[UIImagePickerController alloc] init];
        imagepc.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagepc.delegate = self;
        imagepc.allowsEditing = YES;
        imagepc.cameraDevice = UIImagePickerControllerCameraDeviceRear;
        
    }else if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]){
        NSLog(@"用后置摄像头");
        imagepc = [[UIImagePickerController alloc] init];
        imagepc.cameraDevice = UIImagePickerControllerCameraDeviceFront;
    }else{
        UIAlertController *a = [UIAlertController alertControllerWithTitle:@"调用失败" message:@"请从手机相册中选择" preferredStyle:UIAlertControllerStyleAlert];
        [self presentViewController:a animated:YES completion:nil];
    }
    
    [self presentViewController:imagepc animated:YES completion:nil];
}

//从手机的图片获取
- (void)pickerPictureFromAlbum{
    UIImagePickerController *imgpicker = [[UIImagePickerController alloc] init];
    imgpicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imgpicker.allowsEditing = YES;
    imgpicker.delegate = self;
    [self presentViewController:imgpicker animated:YES completion:nil];
    
}

#pragma -mark UIImagePickerControllerDelegate
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
    if (_MyTags == 1) {
        view.image1.image = [info objectForKey:UIImagePickerControllerEditedImage];
    }else if (_MyTags == 2){
        view.image2.image = [info objectForKey:UIImagePickerControllerEditedImage];
    }else{
        view.image3.image = [info objectForKey:UIImagePickerControllerEditedImage];
    }
    UIImage *img = [info objectForKey:UIImagePickerControllerEditedImage];
    //存入相册
    //UIImageWriteToSavedPhotosAlbum(imageView.image, nil, nil, nil);
    [self loadImage:img];
    
    [self dismissViewControllerAnimated:YES completion:nil];
}
//取消
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [self dismissViewControllerAnimated:YES completion:nil];
}

//
- (void)loadImage:(UIImage *)image{
    NSMutableDictionary *parmas = [NSMutableDictionary dictionary];
    [parmas setObject:@"pic.png" forKey:@"pic"];
    [parmas setObject:@"name" forKey:@"name"];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString *url = [NSString stringWithFormat:@"%@/App/Norm/upload",urlHead];
    [manager POST:url parameters:parmas constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
        NSString *fileName = [NSString stringWithFormat:@"%@.png",[formatter stringFromDate:[NSDate date]]];
        NSData *data = UIImageJPEGRepresentation(image, 0.5);
        [formData appendPartWithFileData:data name:@"pic" fileName:fileName mimeType:@"image/png"];
        [formData appendPartWithFileData:data name:@"name" fileName:fileName mimeType:@"image/png"];
        
    } success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *op = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil];
        NSLog(@"dic:%@",op);
        NSString *error = [NSString stringWithFormat:@"%li",[[op objectForKey:@"error"] integerValue]];
        if ([error integerValue] == 200 && _MyTags == 1) {
            _imgUrl1 = [op objectForKey:@"result"];
            NSLog(@"imgUrl1:%@",_imgUrl1);
        }else if ([error integerValue] == 200 && _MyTags == 2){
            _imgUrl2 = [op objectForKey:@"result"];
            NSLog(@"imgUrl2:%@",_imgUrl2);
        }else{
            _imgUrl3 = [op objectForKey:@"result"];
            NSLog(@"imgUrl3:%@",_imgUrl3);
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"error:%@",error);
    }];
    
}

- (void)click1{
    bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenHeight-250, ScreenWidth, 250)];
    bottomView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.view addSubview:bottomView];
    
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn1.frame = CGRectMake(10, 5, 40, 30);
    [btn1 setTitle:@"取消" forState:UIControlStateNormal];
    [btn1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [btn1 addTarget:self action:@selector(clickCancel) forControlEvents:UIControlEventTouchUpInside];
    [bottomView addSubview:btn1];
    
    UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn2.frame = CGRectMake(ScreenWidth-50, 5, 40, 30);
    [btn2 setTitle:@"确定" forState:UIControlStateNormal];
    [btn2 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [btn2 addTarget:self action:@selector(clickSure) forControlEvents:UIControlEventTouchUpInside];
    [bottomView addSubview:btn2];
    
    UIPickerView *picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, ScreenWidth, 210)];
    picker.delegate = self;
    picker.dataSource = self;
    picker.backgroundColor = [UIColor whiteColor];
    [bottomView addSubview:picker];
    
}

- (void)clickCancel{
    [bottomView removeFromSuperview];
}

- (void)clickSure{
    if (_titles.length > 0) {
        view.labSelType.text = _titles;
        [bottomView removeFromSuperview];
    }
}

#pragma mark - PickerView Delegate
// 列数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

// 每列有多少行
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return arr.count;
}
// 返回每一行的内容
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    NSString *str = [[arr objectAtIndex:row] objectForKey:@"typename"];
    
    return str;
}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    _titles = [[arr objectAtIndex:row] objectForKey:@"typename"];
    _merchanttype = [NSString stringWithFormat:@"%li",[[arr[row] objectForKey:@"id"] integerValue]];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [[UIApplication sharedApplication].keyWindow endEditing:YES];
}
//商家类型
- (void)loadData{
    NSString *url = [NSString stringWithFormat:@"%@/App/Forbusiness/merchanttype",urlHead];
    [[AFHTTPSessionManager manager] POST:url parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        //NSLog(@"res:%@",responseObject);
        arr = [responseObject objectForKey:@"result"];
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}

//入驻资料详情
- (void)loadData2{
    [SVProgressHUD show];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
    NSString *str = [NSString stringWithFormat:@"%@890d69e502d1d37a9e84335ccefece57",[user objectForKey:@"token2"]];
    NSString *token = [LCMD5Tool md5:str];
    NSMutableDictionary *parmas = [NSMutableDictionary dictionary];
    [parmas setObject:[user objectForKey:@"userid"] forKey:@"userid"];
    [parmas setObject:token forKey:@"verifiToken"];
    [parmas setObject:_merid forKey:@"id"];
    NSString *url = [NSString stringWithFormat:@"%@/App/Forbusiness/shopdetails",urlHead];
    [[AFHTTPSessionManager manager] POST:url parameters:parmas success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"入驻资料res:%@",responseObject);
        NSString *error = [NSString stringWithFormat:@"%li",[[responseObject objectForKey:@"error"] integerValue]];
        if ([error integerValue] == 200) {
            dic = [responseObject objectForKey:@"result"];
            _imgUrl1 = [dic objectForKey:@"idcardfront"];
            _imgUrl2 = [dic objectForKey:@"idcardreverse"];
            _imgUrl3 = [dic objectForKey:@"license"];
            
            [self loadUI2];
        }
        [SVProgressHUD dismiss];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"error:%@",error);
        [SVProgressHUD dismiss];
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
